package com.kkd.kkdapp.adapter;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.kkd.kkdapp.R;
import com.kkd.kkdapp.base.MyBaseAdapter;
import com.kkd.kkdapp.http.entity.EverydayDealData1;

public class EverydayDealDetailsAdapter extends
		MyBaseAdapter<EverydayDealData1> {

	public EverydayDealDetailsAdapter(Context context) {
		super(context);
	}

	@Override
	public View getMyView(int position, View convertView, ViewGroup parent) {
		ViewHodler mViewHodler;
		if (convertView == null) {
			convertView = View.inflate(context,
					R.layout.everyday_listview_item, null);
			mViewHodler = new ViewHodler();
			convertView.setTag(mViewHodler);
			mViewHodler.deal_title = (TextView) convertView
					.findViewById(R.id.deal_title);
			mViewHodler.deal_timer = (TextView) convertView
					.findViewById(R.id.deal_timer);
			mViewHodler.deal_money = (TextView) convertView
					.findViewById(R.id.deal_money);
			mViewHodler.line = convertView.findViewById(R.id.line);
		} else {
			mViewHodler = (ViewHodler) convertView.getTag();
		}
		if (position == 0) {
			mViewHodler.line.setVisibility(View.GONE);
		} else {
			mViewHodler.line.setVisibility(View.VISIBLE);
		}
		List<EverydayDealData1> mList = this.getAdapterData();
		if (mList.get(position).getType() == -1) { // 转出
			mViewHodler.deal_money.setTextColor(Color.parseColor("#38BCA4"));
		} else if (mList.get(position).getType() == 1) { // 转入
			mViewHodler.deal_money.setTextColor(Color.parseColor("#FF7301"));
		} else if (mList.get(position).getType() == 2) { // 收益
			mViewHodler.deal_money.setTextColor(Color.parseColor("#FF7301"));
		}
		mViewHodler.deal_title.setText(mList.get(position).getSummary()+"(元)");
		mViewHodler.deal_timer.setText(mList.get(position).getCreateTime());
		mViewHodler.deal_money.setText(mList.get(position).getAmount());
		return convertView;
	}

	class ViewHodler {
		TextView deal_title;
		TextView deal_timer;
		TextView deal_money;
		View line;
	}

}
